<?php

/* Copyright (c) 2007 Alec Henriksen
 * phpns is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public Licence (GPL) as published by the Free
 * Software Foundation; either version 2 of the Licence, or (at your option) any
 * later version.
 * Please see the GPL at http://www.gnu.org/copyleft/gpl.html for a complete
 * understanding of what this license means and how to abide by it.
*/

$globalvars['version'] = "2.1.1b";  // define phpns version. :)

session_start(); //start session management

include("inc/config.php");   // include database information
include("inc/errors.php");   // include error profiles
include("inc/function.php"); // include function header

if (!$globalvars['pagetype']) {
	$globalvars['pagetype'] = "admin"; //set admin pagetype if no pagetype detected. :)
}

if ($globalvars['pagetype'] == "admin" || $globalvars['pagetype'] == "about") {
	include("inc/auth.php"); //include auth info if pagetype is admin (not login page)
}

if (!$globalvars['page_name']) { //display error if there is no content.
			$globalvars['page_name'] = 'error';
			$page_desc['error'] = "You have reached this page in error! Phpns couldn't find any page with the information supplied. If you think this is a bug in the phpns software, we would appreciate you filing the bug at <a href=\"http://launchpad.net/phpns\">the phpns launchpad website</a>!
			<div class=\"warning\">
				<strong>Before reporting this bug, keep in mind, this is alpha software, and some preference pages may not work yet. If this is the case, we already know, and there is no need to report the bug.</strong>
			</div>";
		}
		

//redirect to install dir if not installed
if ($globalvars['installed'] == "no") {
	header("Location: install/index.php");
}



//connect to mysql database for all files
$mysql['connection'] = @mysql_connect($databaseinfo['host'], $databaseinfo['user'], $databaseinfo['password'])
or die ($error['connection']);

//select mysql database
$mysql['db'] = @mysql_select_db($databaseinfo['dbname'],$mysql['connection'])
or die ($error['database']);

//define ip address
$globalvars['ip'] = $_SERVER['REMOTE_ADDR'];
$globalvars['time'] = time();
$globalvars['time_format'] = 'D M d, Y';

include("inc/global_database.php"); //include global db vars
include("inc/global_files.php");  //global files array
?>
